package StringExercise;
//int indexOf(String s):根据第一次出现的字符找位置下标
//int lastIndexOf(String s):根据最后一次出现的字符找位置下标
public class IndexOfDemo1 {
    public static void main(String[] args) {
        String str1="thinking in java";
        int index1=str1.indexOf("in");
        System.out.println(index1);//2
        index1=str1.indexOf("in",3);
        System.out.println(index1);//5
        index1=str1.lastIndexOf("j");
        System.out.println(index1);//12


        String str2="abcdefghabcd";
        int index2=str2.indexOf("c");
        System.out.println(index2);
        index2=str2.indexOf("a",3);
        System.out.println(index2);
        index2=str2.lastIndexOf("a");
        System.out.println(index2);

    }
}
